package com.wrx.club_management_backend.controller;

import com.wrx.club_management_backend.common.AjaxResult;
import com.wrx.club_management_backend.entity.Comment;
import com.wrx.club_management_backend.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    CommentService commentService;

    @PostMapping("/push")
    public AjaxResult push(@RequestBody Comment comment){
        return this.commentService.push(comment);
    }

    @GetMapping("/{newsId}")
    public AjaxResult get(@PathVariable("newsId") Long newsId){
        List<Comment> comments = commentService.getComments(newsId);
        return AjaxResult.success(comments);
    }

}
